﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace gTray
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool mutexCreated = false;
            System.Threading.Mutex mutex = new System.Threading.Mutex(true, "gTray.exe", out mutexCreated);

            if (!mutexCreated)
            {
                if (MessageBox.Show(
                  "There is already an instance of gTray running. Close that instance before relaunching",
                  "Instance already running",
                  MessageBoxButtons.OK,
                  MessageBoxIcon.Information) == DialogResult.OK)
                {
                    mutex.Close();
                    return;
                }
            }

            //Initialisation Logic
            SettingService.Instance.Instantiate();

            // The usual stuff with Application.Run()
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMain());

            mutex.Close();
        }
    }
}
